home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / netrom.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  6.5 KB  |  209 lines

  1. #ifndef    NR3HLEN
  2. #include "iface.h"
  3. #include "ax25.h"
  4.  
  5. /* net/rom support definitions
  6.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  7.  * non-commercial distribution only.
  8.  */
  9.  
  10. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  11. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  12. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  13. #define NR3NODEHL    7    /* nodes bc header length */
  14.  
  15. #define NRNUMIFACE    10    /* number of interfaces associated */
  16.                 /* with net/rom network layer      */
  17. #define NRNUMCHAINS    17    /* number of chains in the */
  18.                 /* neighbor and route hash tables */
  19. #define NRRTDESTLEN    21    /* length of destination entry in */
  20.                 /* nodes broadcast */
  21. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  22.                 /* nodes packet */
  23.  
  24. /* NET/ROM protocol numbers */
  25. #define NRPROTO_IP    0x0c
  26.  
  27. /* Internal representation of net/rom network layer header */
  28. struct nr3hdr {
  29.     char source[AXALEN] ;    /* callsign of origin node */
  30.     char dest[AXALEN] ;        /* callsign of destination node */
  31.     unsigned ttl ;                /* time-to-live */
  32. } ;
  33.  
  34. /* Internal representation of net/rom routing broadcast destination */
  35. /* entry */
  36. struct nr3dest {
  37.     char dest[AXALEN] ;        /* destination callsign */
  38.     char alias[AXALEN] ;            /* ident, upper case ASCII, blank-filled */
  39.     char neighbor[AXALEN] ;    /* best-quality neighbor */
  40.     unsigned quality ;        /* quality of route for this neighbor */
  41. } ;
  42.  
  43.  
  44. /* net/rom interface table entry */
  45. struct nriface {
  46.     struct iface *iface ;        /* pointer to ax.25 interface */
  47.     char alias[AXALEN] ;        /* alias for this interface's node */
  48.                     /* broadcasts */
  49.     unsigned quality ;        /* net/rom link quality estimate */
  50. } ;
  51.  
  52. /* net/rom neighbor table structure */
  53. struct nrnbr_tab {
  54.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  55.     struct nrnbr_tab *prev ;
  56.     char call[AXALEN] ;        /* call of neighbor + 2 digis max */
  57.     unsigned iface ;        /* offset of neighbor's port in */
  58.                     /* interface table */
  59.     unsigned refcnt ;        /* how many routes for this neighbor? */
  60. } ;
  61.  
  62. #define    NULLNTAB    (struct nrnbr_tab *)0
  63.  
  64.  
  65. /* A list of these structures is provided for each route table */
  66. /* entry.  They bind a destination to a neighbor node.  If the */
  67. /* list of bindings becomes empty, the route table entry is    */
  68. /* automatically deleted.                                       */
  69.  
  70. struct nr_bind {
  71.     struct nr_bind *next ;        /* doubly linked list */
  72.     struct nr_bind *prev ;
  73.     unsigned quality ;        /* quality estimate */
  74.     unsigned obsocnt ;        /* obsolescence count */
  75.     unsigned flags ;
  76. #define    NRB_PERMANENT    0x01        /* entry never times out */
  77. #define NRB_RECORDED    0x02        /* a "record route" entry */
  78.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  79. } ;
  80.  
  81. #define    NULLNRBIND    (struct nr_bind *)0
  82.  
  83.  
  84. /* net/rom routing table entry */
  85.  
  86. struct nrroute_tab {
  87.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  88.     struct nrroute_tab *prev ;
  89.     char alias[AXALEN] ;            /* alias of node */
  90.     char call[AXALEN] ;        /* callsign of node */
  91.     unsigned num_routes ;        /* how many routes in bindings list? */
  92.     struct nr_bind *routes ;    /* list of neighbors */
  93.  
  94. } ;
  95.  
  96. #define    NULLNRRTAB    (struct nrroute_tab *)0
  97.  
  98.  
  99. /* The net/rom nodes broadcast filter structure */
  100. struct nrnf_tab {
  101.     struct nrnf_tab *next ;        /* doubly linked list */
  102.     struct nrnf_tab *prev ;
  103.     char neighbor[AXALEN] ;    /* call of neighbor to filter */
  104.     unsigned iface ;        /* filter on this interface */
  105.     unsigned quality;    /* explicit quality of this node */
  106. } ;
  107.  
  108. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  109.  
  110. /* Structure for handling raw NET/ROM user sockets */
  111. struct raw_nr {
  112.     struct raw_nr *prev;
  113.     struct raw_nr *next;
  114.  
  115.     struct mbuf *rcvq;    /* receive queue */
  116.     char protocol;        /* Protocol */
  117. };
  118. #define    NULLRNR    ((struct raw_nr *)0)
  119.  
  120. /* The interface table */
  121. extern struct nriface Nrifaces[NRNUMIFACE] ;
  122.  
  123. /* How many interfaces are in use */
  124. extern unsigned Nr_numiface ;
  125.  
  126. /* The neighbor hash table (hashed on neighbor callsign) */
  127. extern struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS] ;
  128.  
  129. /* The routes hash table (hashed on destination callsign) */
  130. extern struct nrroute_tab *Nrroute_tab[NRNUMCHAINS] ;
  131.  
  132. /* The nodes broadcast filter table */
  133. extern struct nrnf_tab *Nrnf_tab[NRNUMCHAINS] ;
  134.  
  135. extern char Nr_nodebc[AXALEN];
  136.  
  137. /* filter modes: */
  138. #define    NRNF_NOFILTER    0    /* don't filter */
  139. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  140. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  141.  
  142. /* The filter mode */
  143. extern unsigned Nr_nfmode ;
  144.  
  145. /* The time-to-live for net/rom network layer packets */
  146. extern unsigned short Nr_ttl ;
  147.  
  148. /* The obsolescence count initializer */
  149. extern unsigned Obso_init ;
  150.  
  151. /* The threshhold at which routes becoming obsolete are not broadcast */
  152. extern unsigned Obso_minbc ;
  153.  
  154. /* The quality threshhold below which routes in a broadcast will */
  155. /* be ignored */
  156. extern unsigned Nr_autofloor ;
  157.  
  158. /* Whether we want to broadcast the contents of our routing
  159.  * table, or just our own callsign and alias:
  160.  */
  161. extern int Nr_verbose ;
  162.  
  163. /* The maximum number of routes maintained for a destination. */
  164. /* If the list fills up, only the highest quality routes are  */
  165. /* kept.  This limiting is done to avoid possible over-use of */
  166. /* memory for routing tables in closely spaced net/rom networks. */
  167. extern unsigned Nr_maxroutes ;
  168.  
  169. /* The netrom pseudo-interface */
  170. extern struct iface *Nr_iface ;
  171.  
  172. /* Functions */
  173.  
  174. /* In nr3.c: */
  175. void del_rnr __ARGS((struct raw_nr *rpp));
  176. char *find_nralias __ARGS((char *));
  177. struct nrroute_tab *find_nrroute __ARGS((char *));
  178. void nr_bcnodes __ARGS((unsigned ifno));
  179. void nr_nodercv __ARGS((struct iface *iface,char *source,struct mbuf *bp));
  180. int nr_nfadd __ARGS((char *, unsigned));
  181. int nr_nfdrop __ARGS((char *, unsigned));
  182. void nr_route __ARGS((struct mbuf *bp,struct ax25_cb *iaxp));
  183. int nr_routeadd __ARGS((char *, char *, unsigned,
  184.     unsigned, char *, unsigned, unsigned));
  185. int nr_routedrop __ARGS((char *, char *, unsigned));
  186. int nr_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  187.     int del,int tput,int rel));
  188. void nr_sendraw __ARGS((char *dest,unsigned family,unsigned proto,
  189.     struct mbuf *data));
  190. void nr3output __ARGS((char *dest,struct mbuf *data));
  191. int16 nrhash __ARGS((char *s));
  192. struct raw_nr *raw_nr __ARGS((char));
  193.  
  194. /* In nrcmd.c: */
  195. void donrdump __ARGS((struct nr4cb *cb));
  196. int doroutedump __ARGS((void));
  197. int dorouteinfo __ARGS((int argc,char *argv[],void *p));
  198. int putalias __ARGS((char *to, char *from,int complain));
  199.  
  200. /* In nrhdr.c: */
  201. struct mbuf *htonnr3 __ARGS((struct nr3hdr *));
  202. struct mbuf *htonnrdest __ARGS((struct nr3dest *));
  203. int ntohnr3 __ARGS((struct nr3hdr *, struct mbuf **));
  204. int ntohnrdest __ARGS((struct nr3dest *ds,struct mbuf **bpp));
  205.  
  206. #endif    /* NR3HLEN */
  207.  
  208.  
  209.